<template>
	<view class="wrap" :style="{backgroundImage:`url(${HTTP_REQUEST_URL}/uniapp/homeBg.png?v=${vnum})`}">
		<view class="nav_box" :style="{'padding-top': statusBar + 'px'}">
			<!-- #ifdef MP -->
			<view class="nav_title flex_s" :style="{'height':navBar+'px'}">
			<!-- #endif -->
				<!-- #ifdef H5 -->
				<view class="nav_title flex_s">
				<!-- #endif -->

					<view class="image_box">
						<image :src="HTTP_REQUEST_URL+'/uniapp/logoBg.png'" mode="widthFix"></image>
					</view>
				</view>

			</view>
			<view class="header_box">
				<view class="title_box">
					<image src="@/static/statacImg/home_title.png" mode="widthFix"></image>

				</view>
				<view class="update_box flex_se">
					<text class="iconfont icon-shijian1"></text>
					<text>{{ homeData.update_time || '--' }}</text>
					<view class="open_status">
						{{ homeData.title_xiu || '开盘中' }}
					</view>
				</view>
			</view>
			<view class="notice_box" v-if="noticeList.length">
				<view class='iconfont icon-laba icon_box'></view>
				<view class="swiper_box" :vertical="true" circular autoplay :interval="2000">
					<view class="notice_item line1">
						<next-notice-bar :row="1" :speed="100" :list="noticeList">
							<template #default="{ row, rowIndex, colIndex }">
								<view class="notice-bar-item">
									<rich-text :nodes="row"></rich-text>
								</view>
							</template>
						</next-notice-bar>
					</view>
					<view class='iconfont icon-xiangyou'></view>
				</view>


			</view>
			<view class="content">

				<view class="label-box" v-if="homeData.spot&&homeData.spot.length">
					<view class="label-bg flex_sb">
						<text>现货行情</text>
						<text>{{'Domestic quotes'.toUpperCase()}}</text>
					</view>
					<view class="label-info">
						<view class="label-head">
							<view class="label-head-text">
								产品
							</view>
							<view class="label-head-text">
								回收
							</view>
							<view class="label-head-text">
								销售
							</view>
							<view class="label-head-text">
								高低
							</view>
						</view>
						<view class="label-list" v-for="(item1,index1) in homeData.spot" :key="index1">
							<view class="label-list-text">
								{{ item1.increase.code_name || '--' }}
							</view>
							<view class="label-list-text"
								:class="[{'colorRed':item1.increase.colour_bidprice==1},{'colorGreen':item1.increase.colour_bidprice==2}]">
								{{ item1.bidprice || '0.00' }}
							</view>
							<view class="label-list-text"
								:class="[{'colorRed':item1.increase.colour_bidprice==1},{'colorGreen':item1.increase.colour_bidprice==2}]">
								{{ item1.askprice || '0.00' }}
							</view>
							<view class="label-list-num">
								<view class="colorRed">
									{{ item1.high || '0.00' }}
								</view>
								<view class="colorGreen">
									{{ item1.low || '0.00' }}
								</view>
							</view>
						</view>
					</view>
				</view>



				<view class="label-box">
					<view class="label-bg flex_sb">
						<text>国内行情</text>
						<text>{{'Domestic quotes'.toUpperCase()}}</text>
					</view>
					<view class="label-info">
						<view class="label-head">
							<view class="label-head-text">
								产品
							</view>
							<view class="label-head-text">
								回收
							</view>
							<view class="label-head-text">
								销售
							</view>
							<view class="label-head-text">
								高低
							</view>
						</view>
						<view class="label-list" v-for="(item1,index1) in homeData.domestic" :key="index1">
							<view class="label-list-text">
								{{ item1.increase.code_name || '--' }}
							</view>
							<view class="label-list-text"
								:class="[{'colorRed':item1.increase.colour_bidprice==1},{'colorGreen':item1.increase.colour_bidprice==2}]">
								{{ item1.bidprice || '0.00' }}
							</view>
							<view class="label-list-text"
								:class="[{'colorRed':item1.increase.colour_bidprice==1},{'colorGreen':item1.increase.colour_bidprice==2}]">
								{{ item1.askprice || '0.00' }}
							</view>
							<view class="label-list-num">
								<view class="colorRed">
									{{ item1.high || '0.00' }}
								</view>
								<view class="colorGreen">
									{{ item1.low || '0.00' }}
								</view>
							</view>
						</view>


					</view>
				</view>
				<view class="label-box">
					<view class="label-bg flex_sb">
						<text>国际行情</text>
						<text>{{'Domestic quotes'.toUpperCase()}}</text>
					</view>
					<view class="label-info">
						<view class="label-head">
							<view class="label-head-text">
								产品
							</view>
							<view class="label-head-text">
								回收
							</view>
							<view class="label-head-text">
								销售
							</view>
							<view class="label-head-text">
								高低
							</view>
						</view>
						<view class="label-list" v-for="(item1,index1) in homeData.international" :key="index1">
							<view class="label-list-text">
								{{ item1.increase.code_name || '--' }}
							</view>
							<view class="label-list-text"
								:class="[{'colorRed':item1.increase.colour_bidprice==1},{'colorGreen':item1.increase.colour_bidprice==2}]">
								{{ item1.bidprice || '0.00' }}
							</view>
							<view class="label-list-text"
								:class="[{'colorRed':item1.increase.colour_bidprice==1},{'colorGreen':item1.increase.colour_bidprice==2}]">
								{{ item1.askprice || '0.00' }}
							</view>
							<view class="label-list-num">
								<view class="colorRed">
									{{ item1.high || '0.00' }}
								</view>
								<view class="colorGreen">
									{{ item1.low || '0.00' }}
								</view>
							</view>
						</view>

					</view>
				</view>
			</view>
			<!-- <u-popup :show="showTips" bgColor="transparent" :safeAreaInsetBottom="false" mode="center">
			<view class="show-tips">
				<view class="show-tips-img">
					<image :src="homeTcInfo.imsage" mode="aspectFill"></image>
				</view>
				<view class="show-tips-icon" @click="hideTips">
					<u-icon name="close-circle" color="#fff" size="38"></u-icon>
				</view>
			</view>
		</u-popup> -->


			<!-- <tabBar v-if="!is_diy" :pagePath="'/pages/user/index'"></tabBar> -->
			<!-- #ifdef MP -->
			<hoverBtn @showModal="showModal"></hoverBtn>
			<pageFooter></pageFooter>
			<!-- #endif -->


		</view>
</template>

<script>
	import {
		article_details
	} from '@/api/new_api.js';
	import {
		HTTP_REQUEST_URL,
		HTTP_REQUEST_IMG_URL
	} from '@/config/app.js'
	import hoverBtn from "@/components/hoverBtn/index.vue"
	import tabBar from "@/pages/index/visualization/components/tabBar.vue";
	import pageFooter from '@/components/pageFooter/index.vue'
	import noticeVue from "@/components/notice/notice.vue"
	import {
		getShare,
	} from "@/api/public.js";
	import guide from '@/components/guide/index.vue'
	import Cache from '@/utils/cache';
	import {
		GoldPricen,
		getDiy
	} from '@/api/api.js'
	export default {
		components: {
			guide,
			tabBar,
			pageFooter,
			hoverBtn,
			noticeVue
		},
		data() {
			return {
				HTTP_REQUEST_URL,
				is_diy: uni.getStorageSync('is_diy'),
				userInfo: {},
				homeTcInfo: {},
				showTips: false,
				text1: '',
				intervalId: null,
				scrollLeft: 0,
				goodsList: [],
				goodsIndex: -1,
				homeData: [],
				newsData: {
					title: '阿萨德阿萨德阿萨德阿萨德阿萨德阿萨德'
				},
				tabelList: [],
				tabelIndex: 0,
				navigatorHeight: 40,
				statusBar: this.statusBar || 25,
				navBar: this.navBar || 40,
				totalHeight: 40,
				shareInfo: {},
				vnum: 0,
				noticeList: []
			}
		},
		onShow() {
			this.getGoldPricen();
			this.startAutoRefresh();
		},
		onLoad() {
			this.vnum = Math.random() / 999
			this.setOpenShare();
			this.article_details() //获取公告数据
		},
		onUnmounted() {
			if (this.intervalId) {
				clearInterval(this.intervalId);
			}
		},
		onUnload() {
			if (this.intervalId) {
				clearInterval(this.intervalId);
			}
		},
		onHide() {
			if (this.intervalId) {
				clearInterval(this.intervalId);
			}
		},
		methods: {
			article_details() {
				article_details({
					id: 9
				}).then((res) => {

					const data = res.data
					if (data.content) {
						this.noticeList = [data.content]
					}

				})
			},
			setOpenShare: function() {
				let that = this;
				getShare().then((res) => {
					let data = res.data;
					this.shareInfo = data;
				});
			},
			openPop() {
				// 通过组件定义的ref调用uni-popup方法 ,如果传入参数 ，type 属性将失效 ，仅支持 ['top','left','bottom','right','center']
				this.$refs.popup.open()
			},
			// 打开企业微信弹窗
			showModal(bool) {
				this.openPop()
				console.log(bool, "打开企业微信");
			},

			getGoldPricen() {
				GoldPricen().then((res) => {
					this.homeData = res.data;
				}).catch((error) => {
					console.log('error', error, '----------------');
				})
			},
			// hideTips(){
			// 	this.showTips = false;
			// 	uni.showTabBar();
			// },
			startAutoRefresh() {
				if (this.intervalId) clearInterval(this.intervalId);
				this.intervalId = setInterval(() => {
					this.getGoldPricen();
				}, 1000); // 每5秒刷新一次
			},

			// getListNews(){
			// 	ListNews().then((res)=>{
			// 		this.newsData = res.data;
			// 	}).catch((error) =>{
			// 		console.log('error',error,'----------------');
			// 	})
			// },
			// handelTabel = (index) =>{
			// 	this.tabelIndex = index;
			// }
		},
		onShareAppMessage() {
			return {
				title: this.shareInfo.title,
				path: "/pages/home/index?spid=" + this.$store.state.app.uid || 0,
				imageUrl: this.shareInfo.img,
			};
		},
		onShareTimeline() {
			return {
				title: this.shareInfo.title,
				query: {
					spid: this.$store.state.app.uid || 0
				},
				imageUrl: this.shareInfo.img,
			};
		},
	}
</script>


<style lang="scss" scoped>
	.notice_box {
		width: 702rpx;
		height: 60rpx;
		line-height: 60rpx;
		border-radius: 12rpx;
		background: #fff;
		overflow: hidden;
		margin: 20rpx auto;
		padding: 0rpx 24rpx;

		.icon_box {
			float: left;
			margin-right: 10rpx;
			font-size: 28rpx;
			color: #BA0006;
		}

		.swiper_box {
			float: right;
			height: 100%;
			width: 93%;

			.notice_item {
				width: 92%;
				float: left;
				overflow: hidden;
				font-size: 26rpx;
				color: #383838;

				.price {
					color: #D43030;
				}
			}

			.iconfont {
				float: right;
				font-size: 28rpx;
				color: #888;
			}
		}

		.text_box {
			margin-left: 10rpx;
		}
	}

	.colorGreen {
		color: #17a650 !important;
	}

	.colorRed {
		color: #d90506 !important;
	}

	.open_status {
		margin-left: 20rpx;
		padding: 0 10rpx;
		height: 38rpx;
		line-height: 38rpx;
		border-radius: 6rpx;
		font-size: 20rpx;
		color: #fff;
		background: #0C9141;
	}

	.header_box {
		.update_box {
			align-items: center;
			width: 690rpx;
			margin: 0 auto;
			color: #F5E9DF;

			.iconfont {
				margin-right: 10rpx;
				font-size: 30rpx;
			}
		}

		.title_box {
			position: relative;
			width: 360rpx;
			// height: 87rpx;
			margin: 0 auto;

			image {
				width: 100%;
				height: 100%;
			}

		}

	}

	.wrap {
		width: 750rpx;
		min-height: 100vh;
		box-sizing: border-box;
		background: rgb(105, 0, 0);
		background-size: 100% 100%;
		background-repeat: no-repeat;

		.content {
			position: relative;
			z-index: 9;
			padding-bottom: 220rpx;

			.label-box {
				margin: 30rpx auto 0;
				width: 690rpx;
				height: auto;
				border-radius: 20rpx;
				background: linear-gradient(90deg, #E9D3C1 0%, #FDF7F2 54.86%, #E8D6C6 100%);
				// box-shadow:inset 0rpx 0rpx 20rpx  #FFFFFF;
				border: 2rpx solid #FFFFFF;

				.label-bg {
					width: 100%;
					text-align: center;
					line-height: 56rpx;
					font-size: 36rpx;
					font-weight: bold;
					position: relative;
					background-repeat: no-repeat;
					background-size: cover;
					color: #7D5A37;
					padding: 16rpx 30rpx;


				}

				.label-info {
					width: 100%;
					height: auto;
					box-sizing: border-box;
					background: rgb(255, 254, 252);
					border-radius: 20rpx;
					overflow: hidden;
					// box-shadow: 0px 0px 4px rgba(215, 179, 113, 0.3), inset 0px 2px 20px rgba(255, 255, 255, 1);

					.label-head {
						margin: 0 auto;
						padding: 0 18rpx;
						width: 100%;
						height: 64rpx;
						color: #384C69;
						background: #F5E9DF;
						display: flex;
						align-items: center;
						justify-content: center;

						.label-head-text {
							width: 25%;
							font-size: 32rpx;
							font-weight: 400;
							text-align: center;
						}
					}

					.label-list {
						margin: 0 auto;
						width: 100%;
						display: flex;
						align-items: center;
						justify-content: center;
						padding: 18rpx 0;
						border-top: 1px solid rgba(246, 226, 188, 1);

						.label-list-text {
							width: 25%;
							font-size: 32rpx;
							font-weight: bold;
							color: #01060D;
							text-align: center;
						}

						.label-list-num {
							width: 25%;
							font-size: 26rpx;
							font-weight: bold;
							color: rgba(217, 5, 6, 1);
							text-align: center;
						}
					}

					.label-list:nth-child(2) {
						border: none !important;
					}

					.label-money-box {
						display: flex;
						align-items: center;
						flex-wrap: wrap;
						padding: 0 20rpx;

						.label-money {
							margin: 8rpx 13rpx;
							width: 300rpx;
							padding: 28rpx 0;
							border-radius: 20rpx;
							background: rgba(255, 255, 255, 1);
							display: flex;
							align-items: center;
							justify-content: center;
							flex-direction: column;

							.label-money-num {
								font-size: 42rpx;
								font-weight: bold;
								color: rgba(217, 5, 6, 1);
								text-align: center;
							}

							.label-money-text {
								margin-top: 12rpx;
								font-size: 30rpx;
								font-weight: 400;
								color: rgba(128, 72, 28, 1);
								text-align: center;
							}
						}
					}
				}
			}


		}

	}

	.show-tips {

		.show-tips-img {
			margin: 0 auto;
			width: 652rpx;
			height: 916rpx;
			font-size: 0;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.show-tips-icon {
			margin-top: 20rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}



	::v-deep {

		.u-notice-bar,
		.bar--u-notice-bar {
			padding: 0 !important;
			width: 600rpx !important;
		}

		.show-tips-icon {
			.icon--u-icon__icon {
				color: rgba(255, 255, 255, 0.75) !important;
			}
		}
	}
</style>